package com.heatingcharge.dto;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * Description: heating_charge_server
 * User: Devin
 * Date: 2019-12-27
 * Time: 14:17
 */
@Data
public class ChargePlanDTO {
    /**
     * 自动增加
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 供暖季ID
     */
    private Integer heatYearId;

    /**
     * 最低收费率
     */
    private BigDecimal minPercent;

    /**
     * 计划名称
     */
    private String planName;

    /**
     * 制定时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date makingTime;

    /**
     * 截止日期
     */
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date stopDate;

    /**
     * 制作人
     */
    private String maker;

    /**
     * 收费总面积
     */
    private BigDecimal totalArea;

    /**
     * 应收采暖费
     */
    private BigDecimal areaPayable;

    /**
     * 实收采暖费
     */
    private BigDecimal actual;

    /**
     * 优惠金额
     */
    private BigDecimal discount;

    /**
     * 减免金额
     */
    private BigDecimal reduction;

    /*
   已缴费户数
    */
    private Integer paid;

    /**
     *
     */
    private Integer normal;

    private float percentage;

    public float getPercentage() {
        if (ObjectUtil.isNotNull(paid)&&ObjectUtil.isNotNull(normal)){
            float v = (float) paid / normal * 100;
            return (float)(Math.round(v*100)/100);
        }
        return 0f;
    }

    /**
     * 热源厂名字
     */
    private String heatSourceName;
    /**
     * 收费员
     */
    private String payee;
}
